import Vue from "vue";
import store from "../store/index";
import VueRouter from "vue-router";
Vue.use(VueRouter);


const routes = [{
		path: "/",
		name: "首页",
		component: () => import( /* webpackChunkName: "Index" */ "@/views/pc/Index.vue"),
		meta: {
			title: '首页',
			// keepAlive: 1,
		},
	},{
		path: "/customerInfo",
		name: "客户信息",
		component: () => import( /* webpackChunkName: "customerInfo" */ "@/views/pc/customerInfo.vue"),
		meta: {
			title: '客户信息',
			// keepAlive: 1,
		},
	},{
		path: "/infoForm",
		name: "客户信息",
		component: () => import( /* webpackChunkName: "infoForm" */ "@/views/pc/infoForm.vue"),
		meta: {
			title: '客户信息',
			// keepAlive: 1,
		},
	},
	{
		path: "/h5",
		name: "h5",
		component: () => import( /* webpackChunkName: "h5" */ "@/views/phone/h5.vue"),
		meta: {
			title: '上传照片及视频',
			// keepAlive: 1,
		},
	},

	
	{
		path: "*",
		redirect: "/",
	},
];

const scrollBehavior = (to, from, savedPosition) => {
	// console.log('滚动行为', to, from, savedPosition)
	// let whiteList = ['/productList', '/supplierGoods']
	// if (whiteList.includes(to.path)) return;
	return {
		x: 0,
		y: 0
	};
};

const router = new VueRouter({
	routes,
	base: "/",
	// mode: "hash",
	mode: "history",
	mounted() {
		document.dispatchEvent(new Event('render-event'))
	},
	scrollBehavior,
});

router.beforeEach((to, from, next) => {
	next();
	// let token = localStorage.getItem("token");
	// let is_login_curr = token;
	// if (!is_login_curr && to.meta.requireAuth) {
	// 	alertErr("请先登录");
	// 	next("/login");
	// } else {
	// 	next();
	// }
});

router.afterEach((to, from) => {
	// console.log("切换导航, 重新配置微信分享");
	// wxShare.getSign();
});

export default router;